﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using BlazorProject.Entity;

namespace BlazorProject.Repository
{
    public class SysRightRepository : Repository<SysRight>, ISysRightRepository
    {
        public SysRightRepository(BlazorContext dbContext) : base(dbContext)
        {

        }

        #region 权限管理
        public List<SysRight> GetSysRightListByRoleId(string roleId)
        {
            Expression<Func<SysRight, bool>> exp = a => a.IsAvailable == 1 && a.IsDel == 0;
            var list = _dbContext.SysRight.Where(a => a.SysRoleRight.Any(b => b.RoleCode == roleId) && a.IsAvailable == 1 && a.IsDel == 0).ToList();
            return list;
        }
        public IList<SysRight> GetSysRightList()
        {
            Expression<Func<SysRight, bool>> exp = a => a.IsAvailable == 1 && a.IsDel == 0;
            return _dbContext.SysRight.Where(exp).ToList();
        }
        #endregion
    }
}
